package api

import (
	"gitee.com/shiwjlinux/arm/apps/game"
	"gitee.com/shiwjlinux/arm/conf"
	"gitee.com/shiwjlinux/arm/ioc"
	"github.com/rs/zerolog"
)

func init() {
	ioc.Api.Registry(game.AppName, &ApiHandler{})
}

type ApiHandler struct {
	svc    game.Service
	logger *zerolog.Logger
}

func (h *ApiHandler) Init() error {
	h.svc = ioc.Controller.Get(game.AppName).(game.Service)
	subRouter := conf.C().Application.GinRootRouter().Group(game.AppName)
	h.Registry(subRouter)

	// h.logger = &conf.Logger().With().Str("app", game.AppName).Logger()
	// h.logger = conf.Logger.With().Str("app", game.AppName).Logger()
	// h.logger = conf.Logger().GetLogger()
	h.logger = conf.C().Log.Logger()
	h.logger.With().Str("app", game.AppName)
	return nil
}
